package www.hz.domain.strategy.model.vo;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import www.hz.domain.strategy.service.rule.filter.factory.DefaultLogicFactory;
import www.hz.types.common.Constants;

import java.util.ArrayList;
import java.util.List;

/**
 * @className: StrategyAwardRuleModelVO
 * @Description: 抽奖策略规则规则值对象；值对象，没有唯一ID，仅限育从数据库查询对象
 * @version: v1.８.0
 * @author: hz
 * @date: 2025/3/14 11:07
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class StrategyAwardRuleModelVO {
    private String ruleModels;

    public String[] getCenterRuleModels() {
        if (ruleModels == null || ruleModels.isEmpty()) {
            return new String[0]; // 避免空指针异常
        }
        List<String> centerRuleModelList = new ArrayList<>();
        String[] ruleModelArray = ruleModels.split(Constants.SPLIT);
        for (String ruleModel : ruleModelArray){
            if (DefaultLogicFactory.LogicModel.isCenter(ruleModel)) centerRuleModelList.add(ruleModel);
        }
        return centerRuleModelList.toArray(new String[0]);
    }




}